#ifndef _SIMULATIONSERVER_H_
#define _SIMULATIONSERVER_H_

#include <sys/socket.h>
#include <netinet/in.h>

// #include "Thread.h"
#include "ConfigImport.h"

#if 0
#define MAXLINE 4096
struct SimulationServerParameterStr{
    int client_socket_fd;
    ConfigImport* configPara;
    char messageFromClient[MAXLINE];
};

class ServerFunProvider : public ExecuteFunctionProvider
{
private:
    /* data */
public:
    ServerFunProvider();
    ~ServerFunProvider();
    virtual int RunExecuteFunction(void* args);
};

class SimulationServer 
{
public:
    // SimulationServer(ExecuteFunctionProvider *pExecuteFunctionProvider, int serverPort=5001);
    SimulationServer(int serverPort=5001);
    ~SimulationServer();

    void task();
    static void* clientThreadTask(void* args);

    // 线程相关
private:
    // ExecuteFunctionProvider* m_pExecuteFunctionProvider;

    // TCP服务器相关
private:
    int server_socket_fd;
    int client_socket_fd;
    struct sockaddr_in  server_addr;
    static char  buff[MAXLINE];
    
private:
    // void message_parsing(void* messageData, int messageLen);
};

#else
#define MAXLINE 65536
class TCPServer
{
    private:
        int server_socket_fd;
        int client_socket_fd;
        struct sockaddr_in  server_addr;
        char  buff[MAXLINE];

        bool workingFlag;

    public:
        // void message_parsing(void* messageData, int messageLen);
        bool message_parsing(ConfigImport* sys_config);
        void processShutdown();


    public:
        TCPServer(int serverPort=5001);
        ~TCPServer();

        void task();

};

#endif






#endif
